package com.lxl.commons.mapper.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.workbench.entity.Book;
import com.lxl.workbench.entity.Category;
import com.lxl.workbench.entity.CategoryStaff;

import javax.servlet.jsp.jstl.sql.Result;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 书目的Result转化成List集合
 * @author 北上寻海
 */
public class CategoryMapperImpl implements IMapper {
    @Override
    public List<Category> mapper(Result result) throws SQLException {
        List<Category> list = new ArrayList<>();
        if(result.getRowCount()!=0) {
            for (int i = 0; i < result.getRowCount(); i++) {
                Category category = new Category();
                category.setId((String) result.getRowsByIndex()[i][0]);
                category.setBookType((String) result.getRowsByIndex()[i][1]);
                list.add(category);
            }
        }
        return list;
    }
}
